#include "model.h"

void avions_init()
{
  int i=0;
  int temp2=0;
  //5 avions dans la simulation
  int avions_siml=5;
  int avions_totals=0;
  int avions_capacite[3] = {15000, 10000, 8000};
  /* G��ation des avions et de leurs param�res */
  avions_siml = get_random( avions_totals, 5, 5, 0 );
  
  
  //allocation du tableau de structure
  //calloc met tout a NULL pas besoin de le faire
  core->avions = (t_avion**)calloc(avions_siml,sizeof(t_avion*));
  core->nb_avions = avions_siml;
 
  
  msg("Generating airplanes...\n");
  temp2 = get_random( RAND_MAX, 0, 0, 0 );
  for(i=0; i<avions_siml; i++){
        core->avions[i] = (t_avion*)calloc(1,sizeof(t_avion));
        
        core->avions[i]->identifiant = i+1;
        temp2 += core->avions[i]->identifiant;
        core->avions[i]->depart = get_random( core->nb_aeroports, 1, 1, temp2 );
        temp2 += core->avions[i]->identifiant+1;
        core->avions[i]->caburant = avions_capacite[get_random( 3, 0, 0, temp2 )];
        core->avions[i]->consommation = 100;
        core->avions[i]->x = 0;
        core->avions[i]->y = 0;
        core->avions[i]->sol_air = 0;
        core->avions[i]->station = 1;
        msg("Avion num:%d\nDepart: %d\nCarburant: %d\n\n", core->avions[i]->identifiant, core->avions[i]->depart, core->avions[i]->caburant);
        //my_delay();
  }
  msg("done creating planes\n");
}
